{% extends "mail_aliases/nav.html" %}
{% block title %}HCP - Mail Aliases{% endblock %}

{% block torso %}
<!-- MEDIA include datatable json connection get dragdrop -->

<a href="{{ url('hcp-mail-aliases-new') }}">New Mail Alias</a>
<div id="mail-aliases-table"></div>
{% endblock %}


{% block js %}
{{ super() }}

<script type="text/javascript">
var myDataSource = new YAHOO.util.DataSource("{{ url('hcp-json-mail-aliases') }}");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
myDataSource.responseSchema = {
    resultsList: "mail_aliases", // Dot notation to results array.
    fields: ["mail", "hcpMaildrop", "dn"]
};

// XXX: Escape for URL
// XXX: Dynamic get URL.
var myFormatChange = function(elCell, oRecord, oColumn, oData) {
  elCell.innerHTML = "<a href=\"/mail_aliases/edit/" + oRecord.getData("dn") + "/\">" + oData + "</a>";
};

//XXX: include parser:YAHOO.util.DataSource.parseString?
var myColumnDefs = [
  {key:"mail", label:"Mail Alias", sortable:true, resizeable:true, formatter:myFormatChange},
  {key:"hcpMaildrop", label:"Maildrop", sortable:true, resizeable:true},
];

var myDataTable = new YAHOO.widget.DataTable("mail-aliases-table", myColumnDefs, myDataSource,
  {sortedBy:{key:"mail", dir:"desc"}});

</script>

{% endblock %}
